package com.learning.javaweb_springboot_page_query.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.learning.javaweb_springboot_page_query.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {



    @Select("select * from `user` where id = #{id}")
    User selectById1(int id);


//多表查询
//查询用户及其所有的订单
    @Select("select * from user")
    @Results(
            {

                    @Result(column ="id", property ="id"),
                    @Result(column ="password", property ="password"),
                    @Result(column ="id", property ="orders", javaType = List. class,
                            many=@Many(select ="com.learning.javaweb_springboot_page_query.mapper.OrderMapper.selectByUid" )
                    )
                                    }
                                    )
                    List<User> selectAllUserAndOrders();
}